#define FIXED 1

#define LABEL_SCRIPT \
      public btmode; \
      public eval_mode(m) { \
         new f = m & FIXED; \
         new d = m & DISABLE; \
         if (d) { \
            if (f) set_state(PART:"elm.text", "disabled_horizontal_fixed", 0.0); \
            else set_state(PART:"elm.text", "disabled", 0.0); \
         } else { \
            if (f) set_state(PART:"elm.text", "horizontal_fixed", 0.0); \
            else set_state(PART:"elm.text", "default", 0.0); \
         } \
      } \
      public flag_set(flag) { \
         new m = get_int(btmode) | flag; \
         set_int(btmode, m); eval_mode(m); \
      } \
      public flag_unset(flag) { \
         new m = get_int(btmode) & ~flag; \
         set_int(btmode, m); eval_mode(m); \
      }

group { name: "elm/label/base/default";
   script {
      LABEL_SCRIPT
   }
   styles {
      style { name: "label_style";
         base: "font="FN" font_size=10 text_class=tb_plain align=center color_class=/fg/normal/text";
         tag: "br" "\n";
         tag: "b" "+ font="FNBD" text_class=tb_light";
         ENABLED_TEXTBLOCK_TAGS
      }
      style { name: "label_style_disabled";
         base: "font="FN" font_size=10 text_class=tb_plain align=center color_class=/fg/disabled/text";
         tag: "br" "\n";
         tag: "b" "+ font="FNBD" text_class=tb_light";
         DISABLED_TEXTBLOCK_TAGS
      }
   }
   parts {
      part { name: "label.text.clip"; type: RECT;
         description { state: "default" 0.0;
         }
      }
      part { name: "elm.swallow.background"; type: SWALLOW;
         clip_to: "label.text.clip";
         description { state: "default" 0.0;
         }
      }
      part { name: "elm.text"; type: TEXTBLOCK;
         clip_to: "label.text.clip";
         scale: 1;
         description { state: "default" 0.0;
            rel1.relative: 0.0 0.0;
            rel2.relative: 1.0 1.0;
            text {
               style: "label_style";
               min: 1 1;
            }
         }
         description { state: "horizontal_fixed" 0.0;
            inherit: "default" 0.0;
            fixed: 1 0;
            text.min: 0 1;
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            text.style: "label_style_disabled";
         }
         description { state: "disabled_horizontal_fixed" 0.0;
            inherit: "horizontal_fixed" 0.0;
            text.style: "label_style_disabled";
         }
      }
   }
   programs {
      program { signal: "elm,state,horizontal,expandable"; source: "elm";
         script { flag_unset(FIXED); }
      }
      program { signal: "elm,state,horizontal,fixed"; source: "elm";
         script { flag_set(FIXED); }
      }
      program { signal: "elm,state,disabled"; source: "elm";
         script { flag_set(DISABLE); }
      }
      program { signal: "elm,state,enabled"; source: "elm";
         script { flag_unset(DISABLE); }
      }
   }
}

group { name: "elm/label/base/default/left";
   inherit: "elm/label/base/default";
   script {
      LABEL_SCRIPT
   }
   styles {
      style { name: "label_style_left";
         base: "font="FN" font_size=10 text_class=tb_plain align=left color_class=/fg/normal/text";
         tag: "br" "\n";
         tag: "b" "+ font="FNBD" text_class=tb_light";
         ENABLED_TEXTBLOCK_TAGS
      }
      style { name: "label_style_left_disabled";
         base: "font="FN" font_size=10 text_class=tb_plain align=left color_class=/fg/disabled/text";
         tag: "br" "\n";
         tag: "b" "+ font="FNBD" text_class=tb_light";
         DISABLED_TEXTBLOCK_TAGS
      }
   }
   parts {
      textblock { "elm.text";
         desc { "default"; text.style: "label_style_left"; }
         desc { "horizontal_fixed"; text.style: "label_style_left"; }
         desc { "disabled"; text.style: "label_style_left_disabled"; }
         desc { "disabled_horizontal_fixed"; text.style: "label_style_left_disabled"; }
      }
   }
}

group { name: "elm/label/base/default/right";
   inherit: "elm/label/base/default";
   script {
      LABEL_SCRIPT
   }
   styles {
      style { name: "label_style_right";
         base: "font="FN" font_size=10 text_class=tb_plain align=right color_class=/fg/normal/text";
         tag: "br" "\n";
         tag: "b" "+ font="FNBD" text_class=tb_light";
         ENABLED_TEXTBLOCK_TAGS
      }
      style { name: "label_style_right_disabled";
         base: "font="FN" font_size=10 text_class=tb_plain align=right color_class=/fg/disabled/text";
         tag: "br" "\n";
         tag: "b" "+ font="FNBD" text_class=tb_light";
         DISABLED_TEXTBLOCK_TAGS
      }
   }
   parts {
      textblock { "elm.text";
         desc { "default"; text.style: "label_style_right"; }
         desc { "horizontal_fixed"; text.style: "label_style_right"; }
         desc { "disabled"; text.style: "label_style_right_disabled"; }
         desc { "disabled_horizontal_fixed"; text.style: "label_style_right_disabled"; }
      }
   }
}

group { name: "elm/label/base/marker";
   inherit: "elm/label/base/default";
   script {
      LABEL_SCRIPT
   }
   styles {
      style { name: "label_style2";
         base: "font="FNBD" font_size=10 text_class=tb_plain align=center color_class=/fg/normal/text";
         tag: "br" "\n";
         tag: "hilight" "+ font="FNBD" color_class=/fg/normal/text-standout text_class=tb_light";
         tag: "b" "+ font="FNBD" color_class=/fg/normal/text-standout text_class=tb_light";
      }
      style { name: "label_style2_disabled";
         base: "font="FNBD" font_size=10 text_class=tb_plain align=center color_class=/fg/disabled/text";
         tag: "br" "\n";
         tag: "hilight" "+ font="FNBD" color_class=/fg/disabled/text-standout text_class=tb_light";
         tag: "b" "+ font="FNBD" color_class=/fg/disabled/text-standout text_class=tb_light";
      }
   }
   parts {
      textblock { "elm.text";
         desc { "default"; text.style: "label_style2"; }
         desc { "horizontal_fixed"; text.style: "label_style2"; }
         desc { "disabled"; text.style: "label_style2_disabled"; }
         desc { "disabled_horizontal_fixed"; text.style: "label_style2_disabled"; }
      }
   }
}

group { "elm/label/base/marker/left";
   inherit: "elm/label/base/default";
   script {
      LABEL_SCRIPT
   }
   styles {
      style { name: "label_style3";
         base: "font="FNBD" font_size=10 text_class=tb_plain align=left color_class=/fg/normal/text";
         tag: "br" "\n";
         tag: "hilight" "+ font="FNBD" color_class=/fg/normal/text-standout text_class=tb_light";
         tag: "b" "+ font="FNBD" color_class=/fg/normal/text-standout text_class=tb_light";
      }
      style { name: "label_style3_disabled";
         base: "font="FNBD" font_size=10 text_class=tb_plain align=left color_class=/fg/disabled/text";
         tag: "br" "\n";
         tag: "hilight" "+ font="FNBD" color_class=/fg/disabled/text-standout text_class=tb_light";
         tag: "b" "+ font="FNBD" color_class=/fg/disabled/text-standout text_class=tb_light";
      }
   }
   parts {
      textblock { "elm.text";
         desc { "default"; text.style: "label_style3"; }
         desc { "horizontal_fixed"; text.style: "label_style3"; }
         desc { "disabled"; text.style: "label_style3_disabled"; }
         desc { "disabled_horizontal_fixed"; text.style: "label_style3_disabled"; }
      }
   }
}

group { "elm/label/base/marker/right";
   inherit: "elm/label/base/default";
   script {
      LABEL_SCRIPT
   }
   styles {
      style { name: "label_style4";
         base: "font="FNBD" font_size=10 text_class=tb_plain align=right color_class=/fg/normal/text";
         tag: "br" "\n";
         tag: "hilight" "+ font="FNBD" color_class=/fg/normal/text-standout text_class=tb_light";
         tag: "b" "+ font="FNBD" color_class=/fg/normal/text-standout text_class=tb_light";
      }
      style { name: "label_style4_disabled";
         base: "font="FNBD" font_size=10 text_class=tb_plain align=right color_class=/fg/disabled/text";
         tag: "br" "\n";
         tag: "hilight" "+ font="FNBD" color_class=/fg/disabled/text-standout text_class=tb_light";
         tag: "b" "+ font="FNBD" color_class=/fg/disabled/text-standout text_class=tb_light";
      }
   }
   parts {
      textblock { "elm.text";
         desc { "default"; text.style: "label_style4"; }
         desc { "horizontal_fixed"; text.style: "label_style4"; }
         desc { "disabled"; text.style: "label_style4_disabled"; }
         desc { "disabled_horizontal_fixed"; text.style: "label_style4_disabled"; }
      }
   }
}

group { name: "elm/label/base/slide_long";
   inherit: "elm/label/base/default";
   script {
      LABEL_SCRIPT
      public g_duration, g_stopslide, g_timer_id, g_anim_id;

      public message(Msg_Type:type, id, ...) {
         if ((type == MSG_FLOAT_SET) && (id == 0)) {
            new Float:duration;
            duration = getfarg(2);
            set_float(g_duration, duration);
         }
      }
      public slide_to_end_anim(val, Float:pos) {
         new stopflag;
         new id;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         set_tween_state(PART:"elm.text", pos, "slide_begin", 0.0, "slide_end", 0.0);
         if (pos >= 1.0) {
            id = timer(0.5, "slide_to_begin", 1);
            set_int(g_timer_id, id);
            emit("elm,state,slide,end","elm");
         }
      }
      public slide_to_end() {
         new stopflag;
         new id;
         new Float:duration;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         duration = get_float(g_duration);
         id = anim(duration, "slide_to_end_anim", 1);
         set_int(g_anim_id, id);
      }
      public slide_to_begin() {
         new stopflag;
         new id;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         set_state(PART:"elm.text", "slide_begin", 0.0);
         id = timer(0.5, "slide_to_end", 1);
         set_int(g_timer_id, id);
      }
      public start_slide() {
         set_int(g_stopslide, 0);
         set_state(PART:"elm.text", "slide_begin", 0.0);
         slide_to_end();
      }
      public stop_slide() {
         new id;
         set_int(g_stopslide, 1);
         id = get_int(g_anim_id);
         cancel_anim(id);
         id = get_int(g_timer_id);
         cancel_timer(id);
         set_state(PART:"elm.text", "default", 0.0);
      }
   }
   parts {
      part { name: "label.text.clip"; type: RECT;
         description { state: "default" 0.0;
         }
      }
      part { name: "elm.text"; type: TEXTBLOCK;
         scale: 1;
         clip_to: "label.text.clip";
         description { state: "default" 0.0;
            rel1.relative: 0.0 0.0;
            rel2.relative: 1.0 1.0;
            align: 0.0 0.0;
            text {
               style: "label_style";
               min: 0 1;
            }
         }
         description { state: "slide_end" 0.0;
            inherit: "default" 0.0;
            rel1.relative: 0.0 0.0;
            rel2.relative: 0.0 1.0;
            align: 1.0 0.0;
            text {
               style: "label_style";
               min: 1 1;
               ellipsis: -1;
            }
            fixed: 1 0;
         }
         description { state: "slide_begin" 0.0;
            inherit: "default" 0.0;
            rel1.relative: 1.0 0.0;
            rel2.relative: 1.0 1.0;
            align: 0.0 0.0;
            text {
               style: "label_style";
               min: 1 1;
               ellipsis: -1;
            }
            fixed: 1 0;
         }
      }
   }
   programs {
      program { name: "start_slide";
         signal: "elm,state,slide,start"; source: "elm";
         script {
            start_slide();
         }
      }
      program { name: "stop_slide";
         signal: "elm,state,slide,stop"; source: "elm";
         script {
            stop_slide();
         }
      }
   }
}


group { name: "elm/label/base/slide_short";
   inherit: "elm/label/base/default";
   script {
      LABEL_SCRIPT
      public g_duration, g_stopslide, g_timer_id, g_anim_id;

      public message(Msg_Type:type, id, ...) {
         if ((type == MSG_FLOAT_SET) && (id == 0)) {
            new Float:duration;
            duration = getfarg(2);
            set_float(g_duration, duration);
         }
      }
      public slide_to_end_anim(val, Float:pos) {
         new stopflag;
         new id;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         set_tween_state(PART:"elm.text", pos, "slide_begin", 0.0, "slide_end", 0.0);
         if (pos >= 1.0) {
            id = timer(0.5, "slide_to_begin", 1);
            set_int(g_timer_id, id);
            emit("elm,state,slide,end","elm");
         }
      }
      public slide_to_end() {
         new stopflag;
         new id;
         new Float:duration;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         duration = get_float(g_duration);
         id = anim(duration, "slide_to_end_anim", 1);
         set_int(g_anim_id, id);
      }
      public slide_to_begin() {
         new stopflag;
         new id;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         set_state(PART:"elm.text", "slide_begin", 0.0);
         id = timer(0.5, "slide_to_end", 1);
         set_int(g_timer_id, id);
      }
      public start_slide() {
         set_int(g_stopslide, 0);
         set_state(PART:"elm.text", "slide_begin", 0.0);
         slide_to_end();
      }
      public stop_slide() {
         new id;
         set_int(g_stopslide, 1);
         id = get_int(g_anim_id);
         cancel_anim(id);
         id = get_int(g_timer_id);
         cancel_timer(id);
         set_state(PART:"elm.text", "default", 0.0);
      }
   }
   parts {
      part { name: "label.text.clip"; type: RECT;
         description { state: "default" 0.0;
         }
      }
      part { name: "elm.text"; type: TEXTBLOCK;
         scale: 1;
         clip_to: "label.text.clip";
         description { state: "default" 0.0;
            rel1.relative: 0.0 0.0;
            rel2.relative: 1.0 1.0;
            align: 0.0 0.0;
            text { style: "label_style";
               min: 0 1;
            }
         }
         description { state: "slide_end" 0.0;
            inherit: "default" 0.0;
            rel1.relative: 1.0 0.0;
            rel2.relative: 1.0 1.0;
            align: 1.0 0.0;
            text { style: "label_style";
               min: 1 1;
               ellipsis: -1;
            }
            fixed: 1 0;
         }
         description { state: "slide_begin" 0.0;
            inherit: "default" 0.0;
            rel1.relative: 0.0 0.0;
            rel2.relative: 0.0 1.0;
            align: 0.0 0.0;
            text { style: "label_style";
               min: 1 1;
               ellipsis: -1;
            }
            fixed: 1 0;
         }
      }
   }
   programs {
      program { name: "start_slide";
         signal: "elm,state,slide,start"; source: "elm";
         script {
            start_slide();
         }
      }
      program { name: "stop_slide";
         signal: "elm,state,slide,stop"; source: "elm";
         script {
            stop_slide();
         }
      }
   }
}

group { name: "elm/label/base/slide_bounce";
   inherit: "elm/label/base/default";
   script {
      LABEL_SCRIPT
      public g_duration, g_stopslide, g_timer_id, g_anim_id;

      public message(Msg_Type:type, id, ...) {
         if ((type == MSG_FLOAT_SET) && (id == 0)) {
            new Float:duration;
            duration = getfarg(2);
            set_float(g_duration, duration);
         }
      }
      public slide_to_end_anim(val, Float:pos) {
         new stopflag;
         new id;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         set_tween_state(PART:"elm.text", pos, "slide_begin", 0.0, "slide_end", 0.0);
         if (pos >= 1.0) {
            id = timer(0.5, "slide_to_begin", 1);
            set_int(g_timer_id, id);
         }
      }
      public slide_to_end() {
         new stopflag;
         new id;
         new Float:duration;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         duration = get_float(g_duration);
         id = anim(duration, "slide_to_end_anim", 1);
         set_int(g_anim_id, id);
      }
      public slide_to_begin_anim(val, Float:pos) {
         new stopflag;
         new id;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         set_tween_state(PART:"elm.text", pos, "slide_end", 0.0, "slide_begin", 0.0);
         if (pos >= 1.0) {
            id = timer(0.5, "slide_to_end", 1);
            set_int(g_timer_id, id);
            emit("elm,state,slide,end","elm");
         }
      }
      public slide_to_begin() {
         new stopflag;
         new id;
         new Float:duration;
         stopflag = get_int(g_stopslide);
         if (stopflag == 1) return;
         duration = get_float(g_duration);
         id = anim(duration, "slide_to_begin_anim", 1);
         set_int(g_anim_id, id);
      }
      public start_slide() {
         set_int(g_stopslide, 0);
         set_state(PART:"elm.text", "slide_begin", 0.0);
         slide_to_end();
      }
      public stop_slide() {
         new id;
         set_int(g_stopslide, 1);
         id = get_int(g_anim_id);
         cancel_anim(id);
         id = get_int(g_timer_id);
         cancel_timer(id);
         set_state(PART:"elm.text", "default", 0.0);
      }
   }
   parts {
      part { name: "label.text.clip"; type: RECT;
         description { state: "default" 0.0;
         }
      }
      part { name: "elm.text"; type: TEXTBLOCK;
         scale: 1;
         clip_to: "label.text.clip";
         description { state: "default" 0.0;
            rel1.relative: 0.0 0.0;
            rel2.relative: 1.0 1.0;
            align: 0.0 0.0;
            text { style: "label_style";
               min: 0 1;
            }
         }
         description { state: "slide_end" 0.0;
            inherit: "default" 0.0;
            rel1.relative: 1.0 0.0;
            rel2.relative: 1.0 1.0;
            align: 1.0 0.0;
            text { style: "label_style";
               min: 1 1;
               ellipsis: -1;
            }
            fixed: 1 0;
         }
         description { state: "slide_begin" 0.0;
            inherit: "default" 0.0;
            rel1.relative: 0.0 0.0;
            rel2.relative: 0.0 1.0;
            align: 0.0 0.0;
            text { style: "label_style";
               min: 1 1;
               ellipsis: -1;
            }
            fixed: 1 0;
         }
      }
   }
   programs {
      program { name: "start_slide";
         signal: "elm,state,slide,start"; source: "elm";
         script {
            start_slide();
         }
      }
      program { name: "stop_slide";
         signal: "elm,state,slide,stop"; source: "elm";
         script {
            stop_slide();
         }
      }
   }
}
#undef FIXED
